
<!DOCTYPE html>
<html>

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="renderer" content="webkit">

    <title>活动-界面</title>
    <meta name="keywords" content="H+后台主题,后台bootstrap框架,会员中心主题,后台HTML,响应式后台">
    <meta name="description" content="H+是一个完全响应式，基于Bootstrap3最新版本开发的扁平化主题，她采用了主流的左右两栏式布局，使用了Html5+CSS3等现代技术">

    <link href="/after/css/bootstrap.min.css?v=3.4.0" rel="stylesheet">
    <link href="/after/css/font-awesome.min.css?v=4.3.0" rel="stylesheet">

    <link href="/after/css/animate.min.css" rel="stylesheet">
    <link href="/after/css/style.min.css?v=3.0.0" rel="stylesheet">

</head>

<body class="gray-bg">

<div class="wrapper wrapper-content animated fadeInUp">
    <div class="row">
        <div class="col-sm-12">

            <div class="ibox">
                <div class="ibox-title">
                    <h5>所有项目</h5>
                    <div class="ibox-tools">
                        <a href="javascript:;" class="btn btn-primary btn-xs" id="addActive">创建新项目</a>
                    </div>
                </div>
                <div class="ibox-content">
                    <div class="row m-b-sm m-t-sm">
                        <div class="col-md-1">
                            <button type="button" id="loading-example-btn" class="btn btn-white btn-sm"><i class="fa fa-refresh"></i> 刷新</button>
                        </div>
                        <div class="col-md-11">
                            <div class="input-group">
                                <input type="text" placeholder="请输入项目名称" class="input-sm form-control"> <span class="input-group-btn">
                                        <button type="button" class="btn btn-sm btn-primary"> 搜索</button> </span>
                            </div>
                        </div>
                    </div>

                    <div class="project-list">

                        <table class="table table-hover">
                            <tbody>
                            <#list result as item>
                                <tr v-for="(item,index) in result">
                                    <td class="project-status">
                                                <span class="label label-primary">进行中
                                    </td>
                                    <td class="project-title">
                                        <a href="project_detail.html">${item.name}--${item.content}</a>
                                        <br/>
                                        <small>创建于 ${item.createTime}</small>
                                    </td>
                                    <td class="project-completion">
                                        <small>当前进度： 48%</small>
                                        <div class="progress progress-mini">
                                            <div style="width: 48%;" class="progress-bar"></div>
                                        </div>
                                    </td>
                                    <td class="project-people">
                                        <a href="projects.html"><img alt="image" class="img-circle" src="img/a3.jpg"></a>
                                    </td>
                                    <td class="project-actions">
                                        <a href="javascript:;" class="btn btn-white btn-sm" onclick="editEvent(${item.id})"><i class="fa fa-folder"></i> 编辑 </a>
                                        <a href="javascript:;" class="btn btn-white btn-sm" onclick="delEvent(${item.id})"><i class="fa fa-pencil"></i> 删除 </a>
                                    </td>
                                </tr>
                            </#list>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<!-- 全局js -->
<script src="/after/js/jquery-2.1.1.min.js"></script>
<script src="/after/js/bootstrap.min.js?v=3.4.0"></script>


<!-- 自定义js -->
<script src="/after/js/content.min.js?v=1.0.0"></script>

<script src="/after/js/vue/vue.min.js"></script>
<script>
    $(document).ready(function(){$("#loading-example-btn").click(function(){btn=$(this);simpleLoad(btn,true);simpleLoad(btn,false)})});function simpleLoad(a,b){if(b){a.children().addClass("fa-spin");a.contents().last().replaceWith(" Loading")}else{setTimeout(function(){a.children().removeClass("fa-spin");a.contents().last().replaceWith(" Refresh")},2000)}};
</script>
<script src="/after/js/laypage/laypage.js" charset="utf-8"></script>
<script src="/after/js/layer/layer.js" charset="utf-8"></script>
<script>
    var app = new Vue({
        el : '#app',
        data : {
            result : []
        }
    });
    var getActivePageList = function(curr) {
        $.ajax({
            url:"/active/findAll.do",
            type:"post",
            dataType:"JSON",
            data : {
                pageNum:curr || 1,
                pageSize:3,
                name:$("#type").val()
            },
            error:function () {
                alert("错误");
            },
            success:function (msg) {
                app.result=msg.page;

                laypage({
                    cont : 'pagenav', //容器。值支持id名、原生dom对象，jquery对象,
                    pages : msg.totalPage, //总页数
                    skin:'#FFFFFF',
                    first : '首页',
                    last : '尾页',
                    curr : curr || 1, //当前页
                    jump : function(obj, first) { //触发分页后的回调
                        if (!first) { //点击跳页触发函数自身，并传递当前页：obj.curr
                            getActivePageList(obj.curr);
                        }
                    }
                });
            }
        });
    }
    getActivePageList();

    //添加功能
    $("#addActive").on("click",function(){

        layer.open({
            type:2,
            title:'添加活动',
            fix:false,
            maxmin:true,
            shadeClose:true,
            area:['1100px','800px'],
            content:'/backstage/HJHAddActive.ftl',
            end:function(){
                top.location.reload();
            }
        })
    })

    //添加删除功能
    var delEvent = function (id) {
        layer.confirm('确定删除？', {
            btn: ['是', '否']
        }, function () {
            //是
            $.ajax({
                type: 'GET',
                dataType: 'json',
                url: '/active/delActive.do',
                data: {
                    id: id
                },
                success: function (msg) {
                    if(msg){
                        top.location.reload();
                        layer.msg('成功删除' + id, {icon: 6});
                    }
                }
            });
            //否
        }, function () {

        });
    }

    //编辑数据_查
    var editEvent = function (id) {
        layer.open({
            type: 2,
            title: '编辑活动',
            fix: false,
            maxmin: true,
            shadeClose: true,
            area:['1100px','800px'],
//            content: '/active/findActive.do?id='+id,
            content: '/backstage/HJHUpdateActive.ftl?id='+id,
            end: function () {
                top.location.reload();
            }
        });
    }

</script>

</body>
</html>